#include <iostream>
#include <string>
#include <osgViewer/Viewer>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/Shape>
#include <osg/Notify>
#include <osg/ShapeDrawable>

using namespace std;
int main(int argc, char **argv)
{ 
    osg::DisplaySettings::instance()->setNumMultiSamples(3);
    osg::DisplaySettings::instance()->setMinimumNumStencilBits(10);
    osg::setNotifyLevel(osg::DEBUG_INFO);
    osg::ref_ptr<osg::Group> root = new osg::Group;

    osg::ref_ptr<osg::Geode> boxNode = new osg::Geode;
    osg::ref_ptr<osg::Box> box = new osg::Box(osg::Vec3(0.0f, 0.0f, 0.0f), 1.0f);
    osg::ref_ptr<osg::ShapeDrawable> shapeDrawable = new osg::ShapeDrawable(box);
    boxNode->addDrawable(shapeDrawable);

    //使用原生的Geometry绘制线条
    osg::ref_ptr<osg::Geode> lineNode = new osg::Geode;
    osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
    vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
    vertices->push_back(osg::Vec3(1.0f, 1.0f, 1.0f));
    osg::ref_ptr<osg::Geometry> line = new osg::Geometry;
    line->setVertexArray(vertices);
    line->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, vertices->size()));
    lineNode->addDrawable(line);
    root->addChild(lineNode);


    root->addChild(boxNode);
    osgViewer::Viewer viewer;
    viewer.setSceneData(root);
    return viewer.run();
    
}